import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    doctorInfo: {
      id: null,
      username: null,
      loginCount: null,
      name: null,
      phone: null,
      email: null,
      address: null,
      age: null,
      gender: null,
      card: null,
      province: null,
      city: null,
      zip: null
    }
  },
  mutations: {
    updateDoctorInfo(state, doctorData) {
      state.doctorInfo.id = doctorData.id;
      state.doctorInfo.username = doctorData.username;
      state.doctorInfo.loginCount = doctorData.loginCount;
      state.doctorInfo.name = doctorData.name;
      state.doctorInfo.phone = doctorData.phone;
      state.doctorInfo.email = doctorData.email;
      state.doctorInfo.address = doctorData.address;
      state.doctorInfo.age = doctorData.age;
      state.doctorInfo.gender = doctorData.gender;
      state.doctorInfo.card = doctorData.card;
      state.doctorInfo.province = doctorData.province;
      state.doctorInfo.city = doctorData.city;
      state.doctorInfo.zip = doctorData.zip;
    },
  },
  actions: {
  },
  modules: {

  },
  getters: {
    getDoctorInfo(state) {
      return state.doctorInfo;
    },
    getDoctorId(state) {
      return state.doctorInfo.id;
    }
  },
  plugins: [createPersistedState()],
})
